{include file="public/header" /}
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/webuploader.css">
<link rel="stylesheet" type="text/css" href="/static/admin/webupload/style.css">
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>修改教师信息</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="form_basic.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" name="add" id="add" method="post" action="{:url('teach_edit')}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">教师姓名：</label>
                            <div class="input-group col-sm-4">
                                <input id="name" type="text" class="form-control" name="name" value="{$teach.name}" >
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">教师编号：</label>
                            <div class="input-group col-sm-4">
                                <input id="teach_sn" type="text" class="form-control" name="teach_sn" value="{$teach.teach_sn}">
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">教师手机：</label>
                            <div class="input-group col-sm-4">
                                <input id="mobile" type="text" class="form-control" name="mobile" value="{$teach.mobile}" readonly="readonly" >
                                <span>作为登录帐号，无法修改</span>
                            </div>
                        </div>

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否班主任：</label>
                            <div class="input-group col-sm-4">
                                <select  class="form-control m-b "  name="is_leader" >
                                    <option value="0" {if condition="$teach['is_leader'] eq 1"}selected{/if} >否</option>
                                    <option value="1" {if condition="$teach['is_leader'] eq 0"}selected{/if} >是</option>
                                </select>
                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">性别：</label>
                            <div class="input-group col-sm-4">
                                <select  class="form-control m-b "  name="sex" >
                                    <option value="0" {if condition="$teach['sex'] eq 0"}selected{/if}>男</option>
                                    <option value="1" {if condition="$teach['sex'] eq 1"}selected{/if}>女</option>
                                </select>
                            </div>
                        </div>



                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所教年级：</label>
                            <div class="input-group col-sm-4">
                                <select  class="form-control m-b "  name="nianji" >
                                    <option value="0" >请选择</option>
                                    {foreach name="nianji" item="val"}
                                    <option value="{$val.id}" {if condition="$teach['nianji'] eq $val.id"}selected{/if} >{$val.nianji}</option>
                                    {/foreach}

                                </select>
                            </div>
                        </div>


                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所教课程：</label>
                            <div class="input-group col-sm-4">
                                <select  class="form-control m-b "  name="course" >
                                    <option value="0" >请选择</option>
                                    {foreach name="course" item="val"}
                                    <option value="{$val.id}" {if condition="$teach['course'] eq $val.id"}selected{/if} >{$val.name}</option>
                                    {/foreach}
                                </select>
                            </div>
                        </div>

                        <!--<div class="hr-line-dashed"></div>-->
                        <!--<div class="form-group">-->
                        <!--<label class="col-sm-3 control-label">头像：</label>-->
                        <!--<div class="input-group col-sm-4">-->
                        <!--<input type="hidden" id="data_photo" name="photo" >-->
                        <!--<div id="fileList" class="uploader-list" style="float:right"></div>-->
                        <!--<div id="imgPicker" style="float:left">选择头像</div>-->
                        <!--<img id="img_data" class="img-circle" height="80px" width="80px" style="float:left;margin-left: 50px;margin-top: -10px;" src="/static/admin/images/head_default.gif"/>-->
                        <!--</div>-->
                        <!--</div>-->

                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
                                <input id="id" type="hidden" class="form-control" name="id" value="{$teach.id}" >
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/webupload/webuploader.min.js"></script>
<script type="text/javascript">

    var $list = $('#fileList');
    //上传图片,初始化WebUploader
    var uploader = WebUploader.create({

        auto: true,// 选完文件后，是否自动上传。
        swf: '/static/admin/webupload/Uploader.swf',// swf文件路径
        server: "{:url('Upload/uploadface')}",// 文件接收服务端。
        duplicate :true,// 重复上传图片，true为可重复false为不可重复
        pick: '#imgPicker',// 选择文件的按钮。可选。

        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/jpg,image/jpeg,image/png'
        },

        'onUploadSuccess': function(file, data, response) {
            $("#data_photo").val(data._raw);
            $("#img_data").attr('src', '/uploads/face/' + data._raw).show();
        }
    });

    uploader.on( 'fileQueued', function( file ) {
        $list.html( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">正在上传...</p>' +
                '</div>' );
    });

    // 文件上传成功
    uploader.on( 'uploadSuccess', function( file ) {
        $( '#'+file.id ).find('p.state').text('上传成功！');
    });

    // 文件上传失败，显示上传出错。
    uploader.on( 'uploadError', function( file ) {
        $( '#'+file.id ).find('p.state').text('上传出错!');
    });

    $(function(){
        $('#add').ajaxForm({
            beforeSubmit: checkForm,
            success: complete,
            dataType: 'json'
        });

        function checkForm(){
//            if( '' == $.trim($('#studentName').val())){
//                layer.msg('请输入学生姓名',{icon:2,time:1500,shade: 0.1}, function(index){
//                    layer.close(index);
//                });
//                return false;
//            }
        }

        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('school/teach')}";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1});
                return false;
            }
        }

    });


    //IOS开关样式配置
    var elem = document.querySelector('.js-switch');
    var switchery = new Switchery(elem, {
        color: '#1AB394'
    });
    var config = {
        '.chosen-select': {},
    }
    for (var selector in config) {
        $(selector).chosen(config[selector]);
    }

</script>
</body>
</html>

